import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { HttpService } from '../../../service/httpService';
import { NativeService } from '../../../service/NativeService';
import { UserService } from '../../../service/userService';
@Component({
  selector: 'page-betting',
  templateUrl: 'betting.html',
})
export class BettingPage {

  private showLoading = true;
  private data:any;
  constructor(public navCtrl: NavController,
              public http:HttpService,
              public nat:NativeService,
              public user:UserService,
              public navParams: NavParams) {

    this.getData();

  }


  getData(){

    let url = "/api/Bet/GetBetList";
    let map = {
      startTime:this.user.registTime,
      endTime:this.nat.dateFormat(new Date(),'yyyy-MM-dd hh:mm:ss'),
      gamePlatform:'',
      pageIndex:0,
      pageSize:30
    };
    let self = this;
    this.http.get(url,map,function (res,err) {
      self.showLoading = false;
      if(!err){
        for(var i=0;i<res.list.length;i++){
          let item = res.list[i];
          item.more = false;
          if(item.Type == 1){
            item.typeStr = "真人投注";
          }else if(item.Type == 2){
            item.typeStr = "彩票投注";
          }else if(item.Type == 3){
            item.typeStr = "体育投注";
          }else if(item.Type == 4){
            item.typeStr = "电子投注";
          }
          if(item.ResultType == 1){
            item.resultStr = "输";
          }else if(item.ResultType == 2){
            item.resultStr = "赢";
          }else if(item.ResultType == 3){
            item.resultStr = "和";
          }else if(item.ResultType == 4){
            item.resultStr = "无效";
          }
        }
        console.log(res.list);
        self.data = res.list;
      }
    })
  }

  moreAction(index){
    this.data[index].more = !this.data[index].more;
  }

}
